<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/8
 * Time: 10:01
 */
namespace app\api\controller;

use \think\Controller;
use think\Request;

class Base extends Controller
{
    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $post = \request()->param();
        $env = 'test';
        if($env == 'test'){
            return true;
        }
        $signature = $post['signature']??'';
        if(empty($signature)){
            output([],0,'缺少签名');
        }
        $post['key'] = 'hifriends2018';
        ksort($post);
        unset($post['signature']);
        $sign = '';
        foreach($post as $k=>$v){
            $sign .= $k . '=' .$v;
        }
        $sign = sha1($sign);  //加密
//        output(['sign'=>$sign,'signature'=>$signature,$post]);
        if($sign == $signature){
            return true;
        }else{
            output([],0,'验签失败');
        }
    }
}